package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectPlansDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.Syntax;
import java.util.List;

/**
 * @version 1.0
 * @description 说明
 * @package com.zzyl.controller
 */
@RestController
@RequestMapping
@Api(tags = "护理计划")
@Slf4j
public class NursingPlanController extends BaseController {
    @Resource
    private NursingPlanService nursingPlanService;

    /*
     * @Author yutong
     * @Param 条件分页查询
     * @return
     **/
    @GetMapping("/nursing/plan/search")
    @ApiOperation("护理计划分页查询")
    public ResponseResult<PageResponse<NursingPlanVo>> search(
            @ApiParam(value = "护理计划名称") @RequestParam(required = false) String planName,
            @ApiParam(value = "当前页码", required = true) @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页大小", required = true) @RequestParam(defaultValue = "10") Integer pageSize,
            @ApiParam(value = "状态值，0:禁用，1:启用", required = true) @RequestParam(defaultValue = "1") Integer status
    ) {
        log.info("plan_name:{},pageNum:{},pageSize:{},status:{}", planName, pageNum, pageSize, status);
        PageResponse<NursingPlanVo> nursingPlanVoPageResponse = nursingPlanService.search(planName, pageNum, pageSize, status);
        return ResponseResult.success(nursingPlanVoPageResponse);
    }

    /*
     * @Author yutong
     * @Param 通过id查询
     * @return
     **/
    @GetMapping("/nursing/plan/{id}")
    @ApiOperation("通过id查询护理计划")
    public ResponseResult<NursingPlanVo> findById(@PathVariable Long id) {
        List<NursingPlanVo> nursingPlanVo = nursingPlanService.findById(id);
        return ResponseResult.success(nursingPlanVo);
    }

    /*
      * @Author yutong
      * @Param 新增护理计划
      * @return
            **/
    @PostMapping("/nursing/plan")
    @ApiOperation("新增护理计划")
    public ResponseResult add(@RequestBody NursingProjectPlansDto nursingProjectPlansDto) {
        nursingPlanService.addNursingProject(nursingProjectPlansDto);
        return ResponseResult.success();
    }

}
